package com.zj.juc.study.threadLocal;

import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;

/**
 * @author 自己的名字
 * @version 1.0.0
 * @ClassName ThreadLocalMapWeakReferenceDemo
 * @Description ThreadLocalMap弱引用
 * @createTime 2025年01月04日 21:24
 */
public class ThreadLocalMapWeakReferenceDemo {

    //虚引用
    public static void main(String[] args) {
        MyObject myObject = new MyObject();
        ReferenceQueue<MyObject> queue = new ReferenceQueue<>();
        PhantomReference<MyObject> phantomReference = new PhantomReference<>(myObject,queue);
    }
}

class MyObject{
    @Override
    protected void finalize() throws Throwable {
        System.out.println("finalize");
    }
}
